package com.itheima_13;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class test_13 {
    public static void main(String[] args) {
        HashMap<Student,String> hm=new HashMap<>();
        Student stu=new Student("张三",23);
        Student stu1=new Student("李四",24);
        Student stu2=new Student("王五",25);
        hm.put(stu,"湖南 长沙");
        hm.put(stu1,"湖北 武汉");
        hm.put(stu2,"北京 朝阳");
        Set<Student> s = hm.keySet();
        for (Student key : s) {
            String value = hm.get(key);
            System.out.println(key+"---"+value);
        }
        System.out.println("=====================");
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"---"+value);
        }
        hm.forEach(
                (Student key,String value )->{
                    System.out.println(key+"---"+value); 
                });
        hm.forEach(
                test_13::accept);
    }

    private static void accept(Student key, String value) {
        System.out.println(key + "---" + value);
    }
}
